<?php
require_once('include/permiss.php');
require_once('include/header.php');
require_once('include/menu.php');
require_once('config.php');
?>
<div class="container">
    <div class="box">
        <div class="box-heading">MÓN ĂN<span class="righ"><a href="addproduct.php?token=<?php if (isset($_SESSION['token'])) echo $_SESSION['token']; ?>">Thêm</a></span></div>
        <div class="box-content">
            <form method="post" action="#">
                <table class="list">
                    <tr bgcolor="#EFEFEF">
                        <th class="remove"><input type="checkbox" /></th>
                        <th class="image">Hình ảnh</th>
                        <th class="modem">Mã sản phẩm</th>
                        <th class="name">Tên sản phẩm</th>
                        <th class="price">Đơn giá</th>
                        <th class="quantity">Thời gian (phút)</th>
                        <th class="quantity">Ngày tạo</th>
                        <th class="quantity">Lượt xem</th>
                        <th class="action">Thao tác</th>
                    </tr>
                    <?php
                    $pdo = $conn->prepare('SELECT * FROM datab_product');
                    $pdo->execute();
                    if ($pdo->rowCount()) {
                        $data = $pdo->fetchAll();
                        foreach ($data as $row) {
                            ?>
                            <tr>
                                <td class="remove"><input type="checkbox" name="ids[]" value="<?php echo $row['product_id'] ?>" /></td>
                                <td class="image">
                                    <img src="../image/data/<?php echo $row['product_image']; ?>" />
                                </td>
                                <td class="modem"><?php echo $row['product_label']; ?></td>
                                <td class="name"><?php echo $row['product_name']; ?></td>                    
                                <td class="price"><?php echo formatMoney($row['product_price']); ?></td>
                                <td class="quantity"><?php echo $row['product_time']; ?></td>
                                <td class="quantity"><?php echo $row['product_adddate']; ?></td>
                                <td class="quantity"><?php echo $row['product_view']; ?></td>
                                <td class="action">
                                    <a href="editproduct.php?product_id=<?php echo $row['product_id'] . "&token=" . $_SESSION['token']; ?>">[Sửa]</a>
                                    <a href='javascript:void(0);' onclick= onDel("delproduct.php?action=del&product_id=<?php echo $row['product_id'] . "&token=" . $_SESSION['token']; ?>")>[Xóa]</a>
                                </td>
                            </tr>
                            <?php
                        }
                    }
                    ?>                        
                </table>
            </form>
        </div>
    </div>    
</div>
<?php
require_once('include/footer.php');
?>
 
